home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BMUG Revelations
/
BMUG Revelations.toast
/
Utilities
/
Random
/
Commodore 64c
/
SOURCE
/
Register.c
< prev
next >
Wrap
Text File
|
1994-03-19
|
2KB
|
85 lines
/*
Commodore 64 Emulator v0.2 Earle F. Philhower III
Copyright (C) 1993-4 (st916w9r@dunx1.ocs.drexel.edu)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "ProcessorTypes.h"
#include "Memory.h"
#include "Vectors.h"
#include "FileTypes.h"
word pc;
byte a, x, y, flags, sp;
void RegisterInitialize()
{
RAM[0]=RAM[1]=47;
SetUpMemoryMap();
pc=WordAt(ResetTo);
sp=255;
flags=4;
}
void SaveRAMFS(FSSpec *spec)
{
short fnum;
long len;
FSpCreate(spec, (OSType)APPLTYPE, (OSType)RAMFTYPE, 0);
FSpOpenDF(spec, fsRdWrPerm, &fnum);
len=sizeof(word); FSWrite(fnum, &len, &pc);
len=sizeof(byte); FSWrite(fnum, &len, &a);
len=sizeof(byte); FSWrite(fnum, &len, &x);
len=sizeof(byte); FSWrite(fnum, &len, &y);
len=sizeof(byte); FSWrite(fnum, &len, &flags);
len=sizeof(byte); FSWrite(fnum, &len, &sp);
len=65536; FSWrite(fnum, &len, RAM);
FSClose(fnum);
}
void LoadRAMFS(FSSpec *spec)
{
short fnum;
long len;
FSpOpenDF(spec, fsRdPerm, &fnum);
len=sizeof(word); FSRead(fnum, &len, &pc);
len=sizeof(byte); FSRead(fnum, &len, &a);
len=sizeof(byte); FSRead(fnum, &len, &x);
len=sizeof(byte); FSRead(fnum, &len, &y);
len=sizeof(byte); FSRead(fnum, &len, &flags);
len=sizeof(byte); FSRead(fnum, &len, &sp);
len=65536; FSRead(fnum, &len, RAM);
FSClose(fnum);
}
void SaveRAM(void)
{
StandardFileReply reply;
StandardPutFile("\pSave RAM Image:", "\pRAM", &reply);
if (reply.sfGood) SaveRAMFS(&(reply.sfFile));
}
void LoadRAM(void)
{
StandardFileReply reply;
StandardGetFile(nil, (short)-1, nil, &reply);
if (reply.sfGood) LoadRAMFS(&(reply.sfFile));
}